﻿using System;
using System.Collections.Generic;

namespace Utils
{
	public static class Date2
	{
		public static IEnumerable<DateTime> GetDatesInRange(DateTime start, DateTime end)
		{
			if (start > end)
			{
				throw new ArgumentException("Start cannot be greater than end", "start");
			}

			List<DateTime> result = new List<DateTime>();

			DateTime currentDate = start.Date;
			while (currentDate <= end.Date) 
			{
				result.Add(currentDate);
				currentDate = currentDate.AddDays(1);
			}

			return result;
		}

		public static IEnumerable<DateTime> GetDatesNotInRange(DateTime start, DateTime end, IEnumerable<DateTime> dates )
		{
			if (start > end)
			{
				throw new ArgumentException("Start cannot be greater than end", "start");
			}

			if (dates == null)
			{
				throw new ArgumentNullException("dates");
			}

			List<DateTime> tempList = new List<DateTime>(dates);
			List<DateTime> result = new List<DateTime>();

			DateTime currentDate = start.Date;
			while (currentDate <= end.Date)
			{
				if (!tempList.Contains(currentDate))
				{
					result.Add(currentDate);	
				}
				currentDate = currentDate.AddDays(1);
			}

			return result;
		}
	}
}
